<template id="main_coach">
	<div class="main">

		<div class="about_us">

			<!--头部-->
			<div class="about_header">

				<div class="about_title">
					<router-link to="/main"><img src="../../assets/images/class/jiantou_03.png" /></router-link>

					<p>我的教练</p>
					<div class="about_select">
						<div class="about_ing"><img src="../../assets/images/class/dian.png" /></div>

					</div>

				</div>
			</div>
			<!--头部结束-->

		</div>
		<!--教练的信息-->
		<div class="about_info">

			<!--教练一-->
			<div class="about_coach" v-for="(item,index) in coach" :key="index">
				<div class="about_coach_kile">
					<router-link to="">
						<dl>
							<dt><img :src="item[0].photo"/></dt>
							<dd>
								<!--姓名-->
								<div class="coach_name">
									<p>{{item[0].name}}</p>

								</div>
								<!--姓名结束-->
								<!--累计课时与粉丝数-->
								<div class="coach_hour">
									<div class="coach_left">
										<div class="coach_xing">
											<el-rate v-model="item[0].star" disabled></el-rate>
										</div>
										<div class="coach_total">累计课时:<span>{{item[0].class_count}}小时</span></div>
									</div>

								</div>
								<!--累计课时与粉丝数结束-->
								<!--好评-->
								<div class="coach_dome">
									<div class="coach_jin">
										<p>好评</p>
										<span>{{item[0].good_rate}}</span>
									</div>
									<font></font>
									<div class="coach_made">
										<p>粉丝数</p><span>{{item[0].thumbs_num}}</span><img src="../../assets/images/class/shou_14.png" /></div>
								</div>

								<!--今日可预约-->
								<div class="coach_data">
									<span style="color: #2d8f90;">{{item[0].isappointment==1 ? '今日可预约' : ''}}</span>
									<span>{{item[0].isappointment==0 ? '今日不可约' : ''}}</span>
									<p>两周内可预约{{item[0].appointmentcount}}天</p>
									<span></span>
								</div>
								<!--今日可预约结束-->

								<!--距离多少米-->
								<div class="coach_range">
									<div class="coach_min">{{major[0]}}</div>
									<div class="coach_min">{{major[1]}}</div>
									<div class="coach_min">{{major[2]}}</div>

								</div>
								<!--距离多少米结束-->

							</dd>
						</dl>

						<div class="about_book">
							<p>已预约{{item[1]}}次</p>
							<div class="about_remove">
								<button @click.stop="relieve(item[0].coachid)">解除绑定</button>
								<button><router-link :to="{path:'/appointment_coach',query:{coachid:item[0].coachid}}">马上预约</router-link></button>
		
							</div>
						</div>

					</router-link>
				</div>
			</div>
			<!--教练一结束-->

		</div>
		<!--教练的信息结束-->

	</div>
</template>

<script>
	export default {
		data() {

			return {
				userid: '',
				page: '',
				coach:[],
				haha: '',
				major: [],
				value1: 2,
				coachid: this.$route.query.coachid,
			}
		},

		computed: {

		},
		created() {
			//let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
			 var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
			let obj = {
				//请求的参数
				sessionid: SESSION_ID.sessionid,
				userid: SESSION_ID.user.id,
				page:1,
			};
			let _this = this
			_this.sessionid = _this.$store.state.sessionid;
			let qs = require('qs');
			this.$axios.post("http://yogahome.top/yujia/user/showMyCoach", qs.stringify(obj), {
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}

			}).then(function(response) {
				_this.coach = response.data.data[1];
				let m = response.data.data[1][0][0].major;
				_this.major = m.split("|");

				

			}).catch(function(error) {
				console.log(error);
			});
		},
		methods: {
			relieve(coachid) {
				//let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
				 var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
				let obj = {
					
					sessionid: SESSION_ID.sessionid,
					userid: SESSION_ID.user.id,
					coachid:coachid,

				};
				let _this = this
				_this.sessionid = _this.$store.state.sessionid;
				let qs = require('qs');
				this.$axios.post("http://yogahome.top/yujia/user/unbindCoachByUser", qs.stringify(obj), {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}

				}).then(function(response) {
					if(response.data.code =='1'){
						alert("解除教练成功")
					}else if(response.data.code =='0'){
					alert("没有教练")
					}

				}).catch(function(error) {
					console.log(error);
				});
				this.$axios.post("http://yogahome.top/yujia/user/showMyCoach", qs.stringify(obj), {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}

				}).then(function(response) {
					_this.coach = response.data.data[1]

				}).catch(function(error) {
					console.log(error);
				});

			},
			
		}
	}
</script>

<style scoped>
	@import "../../assets/css/main_coach.css";
	
</style>
<style>
	.coach_xing .el-rate__item {
		width: 13px;
		margin-right: 2px;
		margin-top: 4px;
	}
	
	.coach_xing .el-rate__icon {
		font-size: 13px;
	}
	
	.el-rate__icon .el-icon-star-on:before {
		width: 12px;
		height: 12px;
	}
</style>